<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
      <el-form-item label="停车场" prop="roleName">
        <el-select v-model="queryParams.plCode" size="small" filterable placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.plCode"
            :label="item.plName"
            :value="item.plCode">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="车牌号" prop="plateNumber">
        <el-input
          v-model="queryParams.plateNumber"
          placeholder="请输入车牌号"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车位号" prop="spaceCode">
        <el-input
          v-model="queryParams.spaceCode"
          placeholder="请输入车位号"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单号" prop="spaceCode">
        <el-input
          v-model="queryParams.orderNo"
          placeholder="请输入订单号"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单状态" prop="status">
        <el-select
          v-model="queryParams.orderStatus"
          placeholder="订单状态"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="支付时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd "
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:role:edit']"
        >修改</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table  :data="roleList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单号" prop="orderSn" width="220" />
      <el-table-column label="订单状态" prop="orderStatusStr"   width="100" />
      <el-table-column label="支付状态" prop="payStatusStr" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="车牌号码" prop="plateNumber" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="进场时身份" prop="orderTypeStr" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="车位编码" prop="parkingSpaceCode" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="车场编码" prop="parkingLotCode" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="是否物业车位" align="center" width="100">
        <template  slot-scope="scope">
          <span>{{scope.row.spaceProperty |getYn}}</span>
        </template>
      </el-table-column>
      <el-table-column label="提现方式" prop="withdrawChannelStr" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="订单描述" prop="orderDesc"   width="150" />
      <el-table-column label="客户号码" prop="mobile" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="车位主号码" prop="spaceOwnerMobile" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="预约时间" prop="createTime" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="车位保留时间" prop="reserveMinutes" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="预约费用" prop="preAmount" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="实际进场时间" prop="enterTime" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="离场时间" prop="leaveTime" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="支付时间" prop="payTime" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="原付金额" prop="amount" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="优惠金额" prop="discountAmount" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="应付金额" prop="totalPaid" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="实付金额" prop="actualAmount" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="网付金额" prop="onlinePaid" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="现金续费金额" prop="preAmount" :show-overflow-tooltip="true" width="150" />
    </el-table>

    <el-dialog width="60%" title="订单修改" :visible.sync="disabledls" top="1vh" append-to-body>
      <orderupdate v-if="disabledls" :cpDatas="cpDatas" @clsoer="clsoer"></orderupdate>
    </el-dialog>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.page"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listPark, getparkSpace,  getorder,delSys, delSysPark,  changeRoleStatus } from "@/api/park/park";
import orderupdate from './orderupdate';

export default {
  name: "Park",
  components: {
    orderupdate
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      orderNo: [],
      cpDatas: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      roleList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层（数据权限）
      openDataScope: false,
      menuExpand: false,
      menuNodeAll: false,
      deptExpand: true,
      deptNodeAll: false,
      options: [],
      // 日期范围
      dateRange: [],
      // 状态数据字典
      statusOptions: [],


      // 查询参数
      queryParams: {
        page: 1,
        size: 10,
        roleName: undefined,
        roleKey: undefined,
        status: undefined
      },
      //子组件
      disabledls: false,
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
    };
  },
  created() {
     //this.getList();
    this.getDicts("sys_park_orderStatus").then(response => {
      this.statusOptions = response.data;
    });
    this.getParkLot();
  },
  methods: {
    /** 查询同步列表 */
    getList() {
      this.loading = true;
      getorder(this.addDatePark(this.queryParams, this.dateRange)).then(
        response => {
          this.roleList = response.data.records;
          this.total = response.data.total;
        }
      );
    },
    // 办理状态
    statusFormat(row, column) {
      return this.getPark(row.operStatus);
    },
    // 保存类型
    statusOperation(row, column) {
      return this.getParkOperation(row.operType);
    },
    //停车场
    getParkLot(){
      getparkSpace().then(
        response =>{
          this.options = response.data;
        }
      )
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.plCode = null
      this.queryParams.orderStatus = null
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.orderNo = selection.map(item => item.orderSn)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },

    //修改
    handleUpdate(row){
      this.cpDatas = this.orderNo;
      this.disabledls = true;
    },
    clsoer(){
      this.disabledls = false;
      this.getList();
    },
  }
};
</script>
